import request from '@/config/axios'

export interface ReportDatasourceResponse {
  id: number
  datasourceName: String
  name: String
  age: number
  clinicalDiagnosisType: String
  germCellsVisible: Boolean
  karyotype: String
  isGeneticFamily: Boolean
  dataType: String
  isReduction: Boolean
  dataPath: String
  ctrlName: String
  files: String
  dataSize: String
  cellCount: number
  geneCount: number
  notes: String
  cellRatios: String
}

export interface TaskVO {
  id: number
  datasourceId: number
  taskName: string
  ctrlId: number
  isReduction: boolean
  status: number
  startTime: Date
  endTime: Date
  notes: string
}

// 查询分析任务列表
export const getTaskPage = async (params) => {
  return await request.get({ url: `/sca/task/page`, params })
}

// 运行任务
export const startTask = async (params) => {
  return await request.get({ url: `/sca/task/start`, params })
}

// 查询分析任务详情
export const getTask = async (id: number) => {
  return await request.get({ url: `/sca/task/get?id=` + id })
}

// 新增分析任务
export const createTask = async (data: TaskVO) => {
  return await request.post({ url: `/sca/task/create`, data })
}

// 修改分析任务
export const updateTask = async (data: TaskVO) => {
  return await request.put({ url: `/sca/task/update`, data })
}

// 删除分析任务
export const deleteTask = async (id: number) => {
  return await request.delete({ url: `/sca/task/delete?id=` + id })
}

// 导出分析任务 Excel
export const exportTask = async (params) => {
  return await request.download({ url: `/sca/task/export-excel`, params })
}

// 查询细胞比例
export function getReportCellRatio(params: any): any {
  return request.get({ url: '/report/cell-ratio/v2', params })
}

// 获取数据源详细信息
export function getReportDatasource(params: any): any {
  return request.get({
    url: '/report/datasource',
    params
  })
}

// 检查生殖或者体细胞是否存在
export function checkCelltypeExist(params: any): any {
  return request.get({
    url: '/report/check-celltype-exist',
    params
  })
}
